class Solution {
    public int evalRPN(String[] tokens) {
        int length = tokens.length;
        if(length == 0) {
            return 0;
        }
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < length; i++) {
            String ss = tokens[i];
            if(ss.equals("+")) {
                int a = stack.pop();
                int b = stack.pop();
                int c = a + b;
                stack.push(c);
            } else if (ss.equals("-")) {
                int a = stack.pop();
                int b = stack.pop();
                int c = b - a;
                stack.push(c);
            } else if (ss.equals("*")){
                int a = stack.pop();
                int b = stack.pop();
                int c = a * b;
                stack.push(c);
            } else if (ss.equals("/")){
                int a = stack.pop();
                int b = stack.pop();
                int c = b / a;
                stack.push(c);
            } else {
                int aa = Integer.parseInt(ss);
                stack.push(aa);
            }
        }
        return stack.pop();
    }
}